# Contributor: Patrycja Rosa <alpine@ptrcnull.me>
# Maintainer: Eric Molitor <eric@molitor.org>
pkgname=refind
pkgver=0.14.2
pkgrel=0
pkgdesc="rEFInd EFI Boot Manager"
url="https://www.rodsbooks.com/refind"
arch="x86_64"
options="!check"  # No test suite.
license="GPL-3.0-only"
depends="bash efibootmgr lsblk"
makedepends="gnu-efi-dev linux-headers"
subpackages="$pkgname-doc"
source="https://sourceforge.net/projects/refind/files/$pkgver/refind-src-$pkgver.tar.gz
	01-missing-always-inline.patch
	10-refind-disable-fortify.patch
	"

prepare() {
	default_prepare

	# Taken from Arch Linux
	# hardcode RefindDir, so that refind-install can find refind_x64.efi
	sed -e 's|RefindDir=\"\$ThisDir/refind\"|RefindDir="/usr/share/refind/"|g' \
			-i refind-install
}

build() {
	make -j 1 all_gnuefi
}

package() {
	install -Dm0755 refind/*.efi -t "$pkgdir"/usr/share/refind
	install -Dm0755 drivers_*/*.efi -t "$pkgdir"/usr/share/refind/drivers_x86_64
	install -Dm0755 gptsync/*.efi -t "$pkgdir"/usr/share/refind/tools_x86_64
	install -Dm0755 refind.conf-sample -t "$pkgdir"/usr/share/refind

	install -Dm0644 docs/man/*.8 -t "$pkgdir"/usr/share/man/man8

	install -Dm0755 mkrlconf mvrefind refind-mkdefault refind-install -t "$pkgdir"/usr/sbin

	cp -r icons $pkgdir/usr/share/refind
}
sha512sums="
76a52ed422ab3d431e6530fae4d13a51e8ed100568d4290207aaee87a84700b077bb79c4f4917027f5286de422954e1872fca288252ec756072d6c075b102e1e  refind-src-0.14.2.tar.gz
cb466feb8b8b1a3c039224866df7e8f4c575cf2c81a1520449e38a6fc5f5b9cfd924944f97780c68addaab7b943dced4ed9c5e668d91e85d6ea49bcd9359e19c  01-missing-always-inline.patch
ccb61e6e5ae0d762932941d7edd5b9a3506db42cfce70ebc57468837799e60fee73b3c568ae603a6ebb677ae702fb5beb5d13b16daf976b954b35047b6f4ecc0  10-refind-disable-fortify.patch
"
